package com.seednia.foundation.framework.service;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.ws.WebFault;

/**
 * Exception thrown when a remote call fails
 * @author ysahn
 *
 */

@XmlRootElement(name = "RemoteException", 
	namespace = "http://seednia.com/core/1.0")
@XmlType(name = "RemoteException")
@XmlAccessorType(XmlAccessType.PROPERTY)
@WebFault( name="RemoteException", 
	targetNamespace="http://seednia.com/framework/1.0")
public class RemoteException extends Exception implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 105361488306024680L;

	private String message = null;
	private String code = null;

	public RemoteException(String message){
		super(message);
		this.message = message;
	}

	public RemoteException(String message, String code){
		this(message);
		setCode(code);
	}

	public RemoteException(RuntimeException ex){
		super(ex);
	}

	public RemoteException(String message, RuntimeException ex){
		super(message, ex);
		this.message = message;
	}

	public RemoteException(String message, RuntimeException ex, String code){
		this(message, ex);
		setCode(code);
	}
	
	public RemoteException(ServiceException ex){
		super(ex);
	}
	public RemoteException(ServiceException ex, String code){
		super(ex);
		setCode(code);
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public String getMessage() {
		return this.message;
	}
	// [2010/09/06 - ysahn] The XmlAccessType.PROPERTY will not serialize 
	// until get/set pair is found 
	public void setMessage(String message) {
		this.message = message;
	}

}